package win.larryzeal.ztree.config;

import org.springframework.web.filter.CharacterEncodingFilter;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;

import javax.servlet.Filter;

/**
 * Created by 张少昆 on 2017/1/9.
 */
public class WebInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
	@Override
	protected Class<?>[] getRootConfigClasses(){
		return new Class<?>[]{AppConfig.class};
	}

	@Override
	protected Class<?>[] getServletConfigClasses(){
		return new Class<?>[]{MvcConfig.class};
	}

	@Override
	protected String[] getServletMappings(){
		return new String[]{"/"};
	}

	@Override
	protected Filter[] getServletFilters(){
		CharacterEncodingFilter encodingFilter = new CharacterEncodingFilter();
		encodingFilter.setEncoding("UTF-8");
		encodingFilter.setForceEncoding(true);

		return new Filter[]{encodingFilter};
	}
}
